package code08_常用类.内部类;

/**
 * @author 黄衡熙
 * @version 1.0
 */
public class Test04_匿名内部类 {
    public static void main(String[] args) {
        SomeClass someClass = new SonClass();
        someClass.doSome();
        SomeClass sc = new SomeClass() {
            @Override
            void doSome() {
                System.out.println("这是匿名内部类实现的方法");
            }
        };
        sc.doSome();
        System.out.println("**************************************");
        OtherInterface otherInterface = new OtherClass();
        otherInterface.doOther();

        OtherInterface oi = new OtherInterface() {
            @Override
            public void doOther() {
                System.out.println("这是匿名内部类实现的方法");
            }
        };
        oi.doOther();
    }
}
//抽象类
abstract class SomeClass {
    abstract void doSome();
}
class SonClass extends SomeClass {

    @Override
    void doSome() {
        System.out.println("SonClass.doSome");
    }
}
interface OtherInterface {
    void doOther();
}
class OtherClass implements OtherInterface {
    @Override
    public void doOther() {
        System.out.println("OtherClass.doOther");
    }
}


